home *** CD-ROM | disk | FTP | other *** search
/ Aminet 1 (Walnut Creek) / Aminet - June 1993 [Walnut Creek].iso / aminet / util / gnu / emacs_src_18_58.lha / emacs-18.58 / lisp / amiga-init.el < prev    next >
Lisp/Scheme  |  1992-08-03  |  5KB  |  172 lines

  1. (global-set-key "\C-z" 'amiga-iconify)
  2. (setq amiga-map (make-keymap))
  3. (global-set-key "\C-x\C-^" amiga-map)
  4.  
  5. (load "amiga-mouse")
  6. (load "amiga-menu")
  7.  
  8. (define-key amiga-map "A" 'previous-line)
  9. (define-key amiga-map "B" 'next-line)
  10. (define-key amiga-map "D" 'backward-char)
  11. (define-key amiga-map "C" 'forward-char)
  12. (define-key amiga-map "?~" 'info)
  13. (define-key amiga-map "T" 'scroll-down)
  14. (define-key amiga-map "S" 'scroll-up)
  15. (define-key amiga-map " @" 'forward-word)
  16. (define-key amiga-map " A" 'backward-word)
  17. (define-key amiga-map "\M-A" 'beginning-of-buffer)
  18. (define-key amiga-map "\M-B" 'end-of-buffer)
  19. (define-key amiga-map "\M-D" 'beginning-of-line)
  20. (define-key amiga-map "\M-C" 'end-of-line)
  21. (define-key amiga-map "\M- \M-@" 'forward-sexp)
  22. (define-key amiga-map "\M- \M-A" 'backward-sexp)
  23. (define-key amiga-map "\M-T" 'scroll-down-1)
  24. (define-key amiga-map "\M-S" 'scroll-up-1)
  25. ; Keypad sequences are handled like normal ones
  26. (define-key amiga-map "K" 'do-nothing) 
  27.  
  28. (defun do-nothing () (interactive))
  29.  
  30. (defun scroll-down-1 ()
  31.   "Move up one line on screen"
  32.   (interactive)
  33.   (scroll-down 1))
  34.  
  35. (defun scroll-up-1 ()
  36.   "Move down one line on screen"
  37.   (interactive)
  38.   (scroll-up 1))
  39.  
  40. ;; ARexx stuff
  41.  
  42. (setq amiga-arexx-processing nil)
  43. (setq amiga-arexx-errors nil)
  44. (defvar amiga-arexx-failat 5
  45.   "Return level from which arexx commands returns cause errors")
  46.  
  47. (defun amiga-arexx-process ()
  48.   (interactive)
  49.   (if (not amiga-arexx-processing)
  50.       (progn
  51.     (setq amiga-arexx-processing t)
  52.     (condition-case nil ; Avoid blocking of processing in case of bugs
  53.         (let (arexxcmd)
  54.           (while (setq arexxcmd (amiga-arexx-get-event))
  55.         (if (listp arexxcmd)
  56.             (setq amiga-arexx-errors (cons arexxcmd amiga-arexx-errors))
  57.             (let ((rc 0) result)
  58.               (condition-case err ; detect errors in arexx command
  59.               (let ((expr (car (read-from-string arexxcmd))))
  60.                 (setq result (prin1-to-string (eval expr))))
  61.             (error (progn
  62.                  (setq rc 20)
  63.                  (setq result (prin1-to-string err)))))
  64.               (amiga-arexx-reply rc result)))))
  65.       (error nil))
  66.     (setq amiga-arexx-processing nil))))
  67.  
  68. (defun amiga-arexx-wait-command (id)
  69.   "Waits for a pending ARexx commands to complete.
  70. Also processes any pending ARexx requests during this interval."
  71.   (amiga-arexx-process)
  72.   (while (amiga-arexx-check-command id)
  73.     (amiga-arexx-wait)
  74.     (amiga-arexx-process)))
  75.  
  76. (defconst amiga-arexx-error-messages
  77. ["No cause"
  78. "Program not found"
  79. "Execution galted"
  80. "Insufficient memory"
  81. "Invalid character"
  82. "Unmatched quote"
  83. "Unterminated comment"
  84. "Clause too long"
  85. "Invalid token"
  86. "Symbol or string too long"
  87. "Invalid message packet"
  88. "Command string error"
  89. "Error return from function"
  90. "Host environment not found"
  91. "Requested library not found"
  92. "Function not found"
  93. "Function did not return value"
  94. "Wrong number of arguments"
  95. "Invalid argument to function"
  96. "Invalid PROCEDURE"
  97. "Unexpected THEN or WHEN"
  98. "Unexpected ELSE or OTHERWISE"
  99. "Unexpected BREAK, LEAVE or ITERATE"
  100. "Invalid statement in SELECT"
  101. "Missing or multiple THEN"
  102. "Missing OTHERWISE"
  103. "Missing or unexpected END"
  104. "Symbol mismatch"
  105. "Invalid DO syntax"
  106. "Incomplete IF or SELECT"
  107. "Label not found"
  108. "Symbol expected"
  109. "Symbol or string expected"
  110. "Invalid keyword"
  111. "Required keyword missing"
  112. "Extraneous characters"
  113. "Keyword conflict"
  114. "Invalid template"
  115. "Invalid TRACE request"
  116. "Unitialized variable"
  117. "Invalid variable name"
  118. "Invalid expression"
  119. "Unbalanced parentheses"
  120. "Nesting limit exceeded"
  121. "Invalid expression result"
  122. "Expression required"
  123. "Boolean value not 0 or 1"
  124. "Arithmetic conversion error"
  125. "Invalid operand"
  126. ]
  127. "The arexx error messages, sorted by number")
  128.  
  129. (defun amiga-arexx-do-command (str as-file)
  130.   "Sends ARexx command STR (like amiga-arexx-send-command). 
  131. If AS-FILE is true, STR is an arexx command, otherwise it is a file name.
  132. Waits for all pending arexx commands to complete (including this one) before
  133. returning."
  134.   (interactive "sARexx command: 
  135. P")
  136.   (let ((id (amiga-arexx-send-command str as-file)))
  137.     (amiga-arexx-wait-command id)
  138.     (let ((err (assq id amiga-arexx-errors)))
  139.       (if err
  140.       (let ((severity (car (cdr err))))
  141.         (setq amiga-arexx-errors (delq err amiga-arexx-errors))
  142.         (if (>= severity amiga-arexx-failat)
  143.         (let* ((error-code (car (cdr (cdr err))))
  144.                (error-message
  145.             (if (< error-code (length amiga-arexx-error-messages))
  146.                 (aref amiga-arexx-error-messages error-code)
  147.                 (format nil "Unknown error %d" error-code))))
  148.           (error "Arexx command failed, level %d, cause %s"
  149.              severity error-message))))))))
  150.  
  151. (define-key amiga-map "X" 'amiga-arexx-process)
  152. (setq amiga-arexx-initialized t) ;; ARexx commands can now be processed.
  153.  
  154. (defun amiga-wb-process ()
  155.   "Process all pending workbench events, ie load all files requested"
  156.   (interactive)
  157.   (let (file)
  158.     (condition-case nil
  159.     (while (setq file (amiga-get-wb-event t))
  160.       (condition-case nil
  161.           (find-file file)
  162.         (error nil)))
  163.       (error nil))))
  164.  
  165. (define-key amiga-map "W" 'amiga-wb-process)
  166. (setq amiga-wb-initialized t) ;; WB events can now be processed.
  167.  
  168. (setq completion-ignore-case t)
  169. ;; Default is no numbered versions on Amiga, because directory searches are too
  170. ;; slow.
  171. (setq version-control 'never) 
  172.